#pragma once
#include <memory>
#include "ISUI.h"

class Wndbase :public WindowImplBase
{
public:
	typedef std::shared_ptr<Wndbase> Ptr;

	Wndbase(LPCTSTR idWnd, LPCTSTR skinFile, WndCallback wndCallback, NotifyCallback notifyCallback);
	~Wndbase();

	HWND Create(HWND hOwner, bool bSubclass);
	void Close(UINT nRet, bool bAsync);

	void SetProgressControl(LPCTSTR ctrlName, int value, int maxValue);
	void SwitchTabLayout(LPCTSTR ctrlName, int indexItem);
	int GetSelectedTabLayout(LPCTSTR ctrlName);

	void SelectControl(LPCTSTR ctrlName, bool bSelected);
	bool IsSelectedControl(LPCTSTR ctrlName);

protected:
	HWND Subclass(HWND hWnd);

	static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
	LRESULT DoWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

	LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override;
	LRESULT OnActivate(WPARAM wParam, LPARAM lParam, BOOL& bHandled) override;
	void Notify(TNotifyUI& msg) override;

	void OnFinalMessage(HWND hWnd) override;


protected:
	CString m_idWnd;
	WndCallback m_wndCallback = nullptr;
	NotifyCallback m_notifyCallback = nullptr;
};

